Does "make javaScript and CSS External" mean to use JavaScript to load CSS and JS?
Make javaScript and CSS External
So开发者_JAVA百科urce.
Does that mean I should use JavaScript to load JavaScript and CSS files ?
No, it means link them with link
and script
elements so they can be downloaded once and cached for subsequent requests.
Good example.
<link rel="stylesheet" type="text/css" media="screen" href="/css/common.css" />
<script type="text/javascript" src="/js/common.js"></script>
If you include the code and styles inline, they must be downloaded per request.
Bad example.
<style type="text/css">
...
</style>
<script type="text/javascript">
...
</script>
However, loading assets with JavaScript can often be a good idea too.
精彩评论