KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Dependency Management & script tag location #3251

Open Michael Menefee opened this topic on on Feb 19 - 3 comments

Michael Menefee commented on Feb 19

Hi, we are seeing issues w/ dependencies like jQuery and Bootstrap being included by KoolReport / widgets and conflicting with versions already in use in our larger application.

Is there an easy way to shut down javascript dependencies being included and "grabbing" the script block content separately from the report view, so we can manage where it is included in the page? For example, I would like to move the "KoolReport.widget.init" call to the end of the page and put it in a specific loading block that fires once page load is complete.

Ideally, I would like to have a way to get a list of scripts, etc. from the widgets and view and have our existing resource management infrastructure handle this, but obviously that's a bigger ask.

Just looking for some ideas as it looks like there are javascript files spread throughout the package in not very easy to override places.

Sebastian Morales commented on Feb 20

That's an interesting idea you suggested. In the next release we will consider support for separating widget's html and init client script so that developers could manage client scripts for their own likes.

Michael Menefee commented on Feb 21

One issue this in specific that this would address - Hitting the script content at the wrong part of page loading can cause elements whose width is managed via script (ApexCharts, D3js, etc.) to overflow boundaries until the next resize event is triggered:

By being able to move the script content / tags to the end of the page, inside a DOM load event, etc, we could fix this, and at the same time, better optimize the page load performance than what we can do today. (and could even include common script content in an external file to take advantage of caching, etc.)

The feature would also ease integration with frameworks that can do dynamic includes and combining content from multiple stages of rendering I would think...

In my head anyway, it seems like it would make sense to move the script parts up out of the widgets to a centralized asset / resource management scheme in the KoolReport class itself (e.g. via getResourceManager, etc.). That way there's only one place to over-ride it if one needed a "glue" class to mediate between KoolReport resources and whatever mechanisms the larger application / framework uses. But just thinking out loud...

Sebastian Morales commented on Apr 11

We would like to let you know a new version, 6.5.0, of KoolReport has been released and you can separate a widget's html and js code by using the following method:

    $htmlJs = LineChart::htmlJs(array(
        ...
    ));
    echo $htmlJs['html'];
    ...
    echo $htmlJs['js']; 

Pls try it and let us know if there's any issue with the method. Rgds,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
suggestion

None