我正在查看SO源代码,看看他们是如何在右侧栏上做div,从相对位置变为固定位置.
我的问题是如何包含这样的代码,这类似于RequireJS或labJS javascript代码只在需要时加载文件或类似的东西?
<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>
解决方法
My question is how is the code included like this,is this something like the RequireJS or labJS javascript code that loads the files only when they are needed or something like that?
是的,但不是两者中的一个 – 这是一个非常小的本土解决方案.您发布的代码片段让JavaScript知道在包含文件时要使用的缓存断路器;它实际上并不包括它们.只有在实际需要文件时才会发生这种情况.
我写了一个blog post,可以深入了解那里发生的事情.