Replace Javascript source file from server with local javascript source

839 Views Asked by At

I'm trying to install Symfony project on a server, which has no connection to the internet.

How can i replace a Javascript source file from server with a local javascript source file using javascript code locally without using plugins?

I have this javascript code in symfony twig:

{% block javascripts %}

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    <script src="//code.highcharts.com/4.1.8/highcharts.js"></script>
    <script src="//code.highcharts.com/4.1.8/modules/exporting.js</script>

{% endblock %}

How can i replace it with something like script src="C:/scripts/jquery.min.js so that the site uses "jquery.min.js" in C drive instead of the one from server?

2

There are 2 best solutions below

0
On

You can download the file from the vendor site. The file location is then based on its relationship to the index.html (or in whatever file you mention the script tag). So if both the js and HTML files are in the same folder you can reference the name with a simple "/fileName.js". Or if it's in the parent folder then "../fileName.js". Sub folder is "/js/fileName.js".

1
On

Download library's and add in you main template. use this construction for example:

{% block javascripts %}
    <script src="{{ asset('assets/assets/lib/jquery/jquery-1.11.2.min.js') }}"></script>
    <script src="{{ asset('assets/assets/lib/bootstrap/js/bootstrap.min.js') }}"></script>
    <script src="{{ asset('assets/assets/lib/mmenu/mmenu.min.js') }}"></script>
    <script src="{{ asset('assets/assets/lib/materialize/js/materialize.min.js') }}"></script>
    <script src="{{ asset('assets/assets/js/main.min.js') }}"></script>
{% endblock %}

P.S. base directory web/