Plugin init check if current page is dashboard Is there an easy way to check if the current page is the Dashboard?
I have a widget that needs several Javascript resources but if I include them in the widget library I get a google maps error that I should not do that.
You have included the Google Maps API multiple times on this page. This may cause unexpected errors.

I could make a workaround and set a static public variable to false after the first include but that would be kinda dirty.

So all I want to know id there is something like

function init()
{
    if (craft()-&gt;isDashBoard()) {
        //include all JS ressources
    }
}


or if there is a better way to include Javascript.
Nope, but you can use the {% includeJsFile %} tag to include the file(s) from your widget template. In whatever template you render in your widget's getBodyHtml() method, add this:

{% includeJsFile "https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" %}


If you need to queue up several files, you'll need several {% includeJsFile %} tags. There's also a {% includeCssFile %}, if you need to add some external CSS, as well.