Reputation: 4299
Make javaScript and CSS External
Does that mean I should use JavaScript to load JavaScript and CSS files ?
Upvotes: 1
Views: 953
Reputation: 490303
No, it means link them with link
and script
elements so they can be downloaded once and cached for subsequent requests.
<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.
<style type="text/css">
...
</style>
<script type="text/javascript">
...
</script>
However, loading assets with JavaScript can often be a good idea too.
Upvotes: 1