meotimdihia
meotimdihia

Reputation: 4299

Does "make javaScript and CSS External" mean to use JavaScript to load CSS and JS?

Make javaScript and CSS External

Source.

Does that mean I should use JavaScript to load JavaScript and CSS files ?

Upvotes: 1

Views: 953

Answers (1)

alex
alex

Reputation: 490303

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.

Upvotes: 1

Related Questions