How does qaru include javascript files?

I looked at the SO source code to see how they make a div in the right sidebar, which changes relative to a fixed position.

I saw that the SO JS library is almost completely included in the page with this code below ...

My question is how is this code included like this, is it something like RequireJS or labJS javascript code that only downloads files when they are needed or something like that?

<script type="text/javascript"> StackExchange.using.setCacheBreakers({ "js/prettify-full.js": "0324556b7bf7", "js/moderator.js": "a38ca3c6143d", "js/full-anon.js": "8fcefa158ad3", "js/full.js": "a168b3deac0f", "js/wmd.js": "688233b2af68", "js/third-party/jquery.autocomplete.min.js": "e5f01e97f7c3", "js/mobile.js": "97644ef9b7d4", "js/help.js": "7f83495f785a", "js/tageditor.js": "75954ba7b6f1", "js/tageditornew.js": "9d9998359a54", "js/inline-tag-editing.js": "364e12111b4b", "js/mathjax-editing.js": "a47e02eb0282", "js/revisions.js": "63c88065da1f" }); </script> 
+6
source share
1 answer

My question is how is this code included like this, is it something like RequireJS or labJS JavaScript code that only downloads files when they are needed or something like that?

Yes, but not one of the two - this is a very tiny home solution. The snippet you posted allows JavaScript to know which cache breakers to use if they contain a file; he does not actually include them. This only happens when the file is really needed.

I wrote a blog post that gives some insight into what is going on there.

+8
source

Source: https://habr.com/ru/post/901880/


All Articles