Currently, we're setting up dependencies inline on a html-page like this
<html>
<body>
<article>
Content
</article>
<script type="text/javascript">
define([
'View',
'Model'
], function(View, Model){
new View({ model: Model });
});
</script>
</body>
</html>
Almost every page where we do this has different dependencies. We stayed away from creating main.js files because it'd mean that we would have a main.js file for every one of these pages.
How would we best use the requirejs optimiser in our case?
I've had much better success architecting my sites so that they share a common main.js. Or at least dividing the site into a small number sections that share builds. It takes some up-front planning, but it's a LOT easier to manage, and takes better advantage of the browser cache than one-build-per-page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With