diff --git a/Language/Elm/Yesod.hs b/Language/Elm/Yesod.hs
--- a/Language/Elm/Yesod.hs
+++ b/Language/Elm/Yesod.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE QuasiQuotes, TypeSynonymInstances #-}
+{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-}
 {- | This module provides a function for compiling Elm source code into a Yesod widget.
      In order to use this with your Yesod app, you need to define a defaultLayout like
      function that embeds the elm-min.js file /in the <head> tag/.
@@ -7,16 +8,16 @@
 
    > instance Yesod App where
    >    jsLoader _ = BottomOfHeadBlocking -- moves JS to the <head> tag
-   >    defaultLayout widget = do
-   >        pc <- widgetToPageContent $ do
-   >            addScriptRemote $ "http://somecdn.org/link/to/elm-min.js"
-   >            ...
-   >        ...
 
-     A full example implementation is provided in the examples folder of the Elm github repository.
+     You also need to define an instance of 'YesodElm', which will specify
+     where to find the elm-min.js file.
+
+     A full example implementation is provided in the examples folder of the Elm github repository
+     at <https://github.com/tazjin/Elm/tree/master/Examples/elm-yesod>.
 -}
 module Language.Elm.Yesod (
         elmWidget
+      , YesodElm (..)
       , ElmUrl) where
 
 import Control.Monad (liftM)
@@ -25,19 +26,32 @@
 import Yesod.Core (Route (..))
 import Yesod.Handler (getUrlRenderParams, GHandler (..))
 import Yesod.Widget
+import Yesod.Handler (lift, getYesod)
 import Language.Elm
 import Language.Elm.Quasi
 
 import qualified Data.Text as TS
 import qualified Data.Text.Lazy as TL
 
+class YesodElm master where
+    -- | The location of the elm-min.js file. This can be either a type-safe
+    -- route (@Left@) or a raw string (@Right@).
+    urlElmJs :: a -> Either (Route master) TS.Text
+
+instance (YesodElm master, render ~ RenderFn (Route master))
+  => ToWidget sub master (render -> Elm) where
+    toWidget = elmWidget
+
 -- |elmWidget returns a Yesod widget from some Elm source code
 --  with URL interpolation.
-elmWidget :: ElmUrl (Route master) -- ^ Elm source code
-          -> GHandler sub master (GWidget sub master())
+elmWidget :: YesodElm master
+          => ElmUrl (Route master) -- ^ Elm source code
+          -> GWidget sub master()
 elmWidget source = do
-  urlF <- getUrlRenderParams
-  return $ mkElmWidget source urlF
+  urlF <- lift getUrlRenderParams
+  mkElmWidget source urlF
+  master <- lift getYesod
+  addScriptEither $ urlElmJs master
 
 
 mkElmWidget :: ElmUrl (Route master)   -- ^ Elm source code
diff --git a/elm-yesod.cabal b/elm-yesod.cabal
--- a/elm-yesod.cabal
+++ b/elm-yesod.cabal
@@ -1,5 +1,5 @@
 Name:                elm-yesod
-Version:             0.1
+Version:             0.1.2
 Synopsis:            The Elm language Yesod compatibility module.
 Description:         This module provides a simple function to embed Elm code
                      as a Yesod widget.
