CDN with fallback in Symfony twig using assetic

223 views Asked by At

I have local copy of Bootstrap which I minify along with other libraries using assetic but reading this solution, I would like to have Bootstrap loaded using CDN and IF the CDN is down only then return the local copy of Bootstrap (minified with other local libraries). How can I achieve this in Twig using Assetic? Current code:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
        <title>{% block title %}Welcome!{% endblock %}</title>

        {% block stylesheets %}
            {% stylesheets filter="cssrewrite, scssphp" output="css/app.css"
                "assets/vendor/bootstrap/dist/css/bootstrap.min.css"
                "assets/vendor/components-font-awesome/css/font-awesome.min.css"
                "assets/vendor/bootstrap-material-design/dist/css/bootstrap-material-design.css"
                "assets/custom-assets/scss/background.scss"
             %}
                <link rel="stylesheet" href="{{ asset_url }}" />
            {% endstylesheets %}
        {% endblock %}

    </head>
    <body>
     ....
    </body>
    </html>
0

There are 0 answers