S
S
Spider84112020-09-30 19:19:24
Client side optimization
Spider8411, 2020-09-30 19:19:24

Optimizing JS for Google page speed - which is better?

Greetings.
Now I am optimizing several projects on Google page speed.
The main problem is, of course, the abundance of Javascript and its long execution.
Questions related to this.
1. At one of the webinars, I heard that it is necessary to organize delayed loading of those scripts that allow it. Is lazy loading a SetTimeout? Or something else?
2. Is it reasonable to connect scripts (including external ones - counters, consultants) by setTimeout like this

<script type="text/javascript">
  jQuery(document).bind("ready", function() {
  setTimeout(function() {
    var script = document.createElement('script');
    script.src = 'адрес скрипта';
    script.type = 'text/javascript';
    document.body.appendChild(script);
  }, 10000);
});
</script>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2020-09-30
@SilenceOfWinter

1. delayed - it means loading them as needed, see jquery ajax methods
2. not reasonable if there is no clear justification for this and reasonable if vice versa

S
Spider8411, 2020-09-30
@Spider8411

And external consultants connect via ajax and how it will be. look like if they connect via

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question