delays...">
<script src="..."></script>
delays page rendering until this script is loaded. If there are dozens of them, this can seriously slow down the work of the site - as a result, the user stares for 20 seconds at an empty (or undeleted) page due to some blunt social widget (multiply by a dozen of these widgets).<script extsrc ="..."></script>
( "extsrc" = " "
) so that the scripts load after the page is rendered?document.write
... Today I finally solved his problem - I imagine extsrc.js - a script that will run all the scripts after the page is rendered (even if they contain document.write
- and everything will be correctly drawn).<script src ="...">
with <script extsrc ="...">
. <script src="http://whiteposts.com/extsrc_js/extsrc.js"></script> <script extsrc="..."></script>
extsrc="..."
are loaded sequentially (due to document.write
), but after the page has been rendered (unlike the usual src="..."
, which forces users to look at the blank page until the script loads) .document.write
(the main argument against 'async' before). <script asyncsrc="..."></script>
extsrc ="..."
there is also asyncsrc ="..."
- faster, but less secure from the point of view of document.write
. Use <script asyncsrc ="..."></script>
if you are sure that there is no document.write
in this particular script.<script asyncsrc="">
is the same as <script defer>
only works in all reasonable browsers (as far as I know).asyncsrc
will load in parallel (accordingly, there is no guarantee which script will load earlier, but of course it is faster than sequentially loading extsrc
). The problem is to combine these two approaches just in the implementation of the replacement document.write
.extsrc="..."
. Sure - write asyncsrc="..."
.script src="..."
do extsrc="..."
, and then one by one we change to asyncsrc = "..." - if nothing is broken.document.write('<script src="...">'); document.write('</script>');
bug document.write('<script src="...">'); document.write('</script>');
document.write('<script src="...">'); document.write('</script>');
also probably fixed. <script extsrc="jquery.js"></script> <script> $(document).ready(....) </script>
$
, and then JQuery will be loaded.$(document).ready(...)
into a separate file and load it as extsrc="..."
.extsrc
) loading of specially slowed down scripts, the page finished loading in 1.2 seconds, while the content appeared for 300ms? (It is difficult to judge by the picture)500
(. Actually, it is difficult to draw conclusions from this, because extsrc
is made for the convenience of the user (so that the content appears as early as possible, and then load what you want).Source: https://habr.com/ru/post/105850/
All Articles