Freezing the Vue.js version to a minor version

Published on 2020-01-23 • Modified on 2020-01-23

This is a small trick that allows the jsdelivr.net CDN network. It's a very bad practice to use the "last" stable available version of a library. Instead, when getting a file, you can specify a tag. The trick here is to set a minor version (eg: 2.6) instead of setting an exact version (eg: 2.6.11). When using 2.6, the last bugfix version will be used so you are sure there no compatibility problem with your code. While developing, we can continue to use the last not minified version. The Twig is_dev() helper test if we are on a local development machine and not in production.


{% if is_dev() %}
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
{% else %}
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6"></script>
{% endif %}

 More on Stackoverflow  More on the web  Random snippet

  Work with me!