froala / KMSFroalaEditorBundle

Symfony bundle for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
105 stars 33 forks source link

Will there be multiple css and/or js files included? #125

Open MichaelBrauner opened 3 years ago

MichaelBrauner commented 3 years ago

I think about to use this bundle for my projects. BUT - I wonder if there will be multiple includes of this css and js files:

 {# CSS. #}
    {% if froala_includeFontAwesome %}
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
    {% endif %}
    {% if froala_includeCodeMirror %}
        <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.css" />
    {% endif %}

    {% if froala_includeCSS %}
        <link rel="stylesheet" type="text/css" href="{{ asset( froala_basePath ~ 'css/froala_editor.min.css' ) }}" />
        <link rel="stylesheet" type="text/css" href="{{ asset( froala_basePath ~ 'css/froala_style.min.css' ) }}" />

        {% if froala_arrOption[ "theme" ] is defined %}
            <link rel="stylesheet" type="text/css" href="{{ asset( froala_basePath ~ 'css/themes/' ~ froala_arrOption[ "theme" ] ~ '.min.css' ) }}" />
        {% endif %}

        {% for plugin in froala_arrPluginCSS %}
            <link rel="stylesheet" type="text/css" href="{{ asset( froala_basePath ~ 'css/' ~ plugin ~ '.min.css' ) }}" />
        {% endfor %}

    {% endif %}

    {# Editor textarea. #}
    <textarea {{ block( "widget_attributes" ) }}>{{ value }}</textarea>

    {# JS. #}

    {% if froala_includeCodeMirror %}
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/mode/xml/xml.min.js"></script>
    {% endif %}

    {% if froala_includeJS %}
        <script type="text/javascript"  src="{{ asset( "bundles/kmsfroalaeditor/misc.js" ) }}"></script>
        <script type="text/javascript"  src="{{ asset( froala_basePath ~ 'js/froala_editor.min.js' ) }}"></script>

        <!--[if lt IE 9]>
        <script type="text/javascript" src="{{ asset( froala_basePath ~ 'js/froala_editor_ie8.min.js' ) }}"></script>
        <![endif]-->
        <script type="text/javascript" src="{{ asset( froala_basePath ~ 'js/languages/' ~ froala_arrOption.language ~ '.js' ) }}"></script>

        {% for plugin in froala_arrPluginJS %}
            <script type="text/javascript" src="{{ asset( froala_basePath ~ 'js/' ~ plugin ~ '.min.js' ) }}"></script>
        {% endfor %}
    {% endif %}

    {% if froala_customJS is defined %}
        <script type="text/javascript"  src="{{ asset( customJS ) }}"></script>
    {% endif %}

I mean - this will be included for every form field, when I have multiple on my pages?

Is that right?

jmsche commented 3 years ago

I think so, that's part of the reason I added Encore build in the docs.

Note CSS/JS files should be downloaded once only though, as the first request returns a 200 status, and the next requests should return a 304 status.

MichaelBrauner commented 3 years ago

Ok, you mean it will be downloaded only once for sure?

jmsche commented 3 years ago

If the server is configured correctly, sure.