Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ivan 41 posts 182 karma points
    Nov 21, 2023 @ 08:34
    ivan
    0

    DependencyHandler add attribute on script and css tag

    Is there any way that I can add defer or async attribute on script tag and css rel=preload generated by client dependency?

    E.g.

    <script src="/DependencyHandler.axd" type="text/javascript" async></script>
    
    
    <link href="/DependencyHandler.axd?cdv=1" type="text/css" rel="preload">
    
  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Nov 22, 2023 @ 14:50
    Marc Goodson
    0

    Hi Ivan

    Golly gosh it's a long time since I looked at the Client Dependency Framework.... but I think.. you can just pass the attributes into the Html.RequiresJs and Html.RequiresCSS helpers eg...

    Html.RequiresJs("site.js", "Scripts", new { async="" })
    
    Html.RequiresCss("~/css/styles.css", new Dictionary<string, string>() { { "rel", "preload" } });
    

    but it's been a while!

    regards

    marc

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies