[web-devel] Yesod: Regarding Widgets and addJulius

Michael Snoyman michael at snoyman.com
Sat May 7 19:34:28 CEST 2011

On Sat, May 7, 2011 at 9:26 AM, Mathew de Detrich <deteego at gmail.com> wrote:
> I seem to have come across a problem regarding javascript and using widgets
> (im using Yesod 0.7.3). I add javascript to widgets normally with addJulius,
> however when they get added into the head of the website, the tags that
> enclose the javascript code are
> <script>
> Instead of
> <script type="text/javascript">
> I also think this is the reason why the javascript is not executing on my
> website
> Also unless I am missing something would it be possible to implement a
> function like addJulius but instead of adding it to the script to the <head>
> html page, the javascript gets concatenated into a .js file (which is
> returned by some route).
> Thanks
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel

Two good questions. For the first: <script> should be supported in all
browsers just as well as <script type="text/javascript">. The reason
Yesod uses the former is that it's the "HTML5" version, which is
favored since it is (1) less bytes and (2) functionally equivalent. If
you're experience problems from this, I'd be very interested to see an

For appending to an external file instead: this is supported by Yesod
via the addStaticContent[1] method of the Yesod typeclass. It's a bit
tricky to get all the details right; I would recommend looking at the
scaffolded site, which does just that. (Run yesod init.)


[1] http://hackage.haskell.org/packages/archive/yesod-core/0.8.1/doc/html/Yesod-Core.html#v:addStaticContent

More information about the web-devel mailing list