web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

JavaScript Line Limitations

(0) ShareShare
ReportReport
Posted on by 7,042

Hi guys.

Whether there is any limitations for number of lines in Java Script? Because for one of my entity i wrote Java Script code and link to ribbon button and it's working fine, But the no.of lines in the code is nearly 1200 (approx).

For the upcoming forms it may cross that line. I need to know whether my script work fine if it has more lines?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Bruno Lucas Profile Picture
    5,421 on at

    There is no real limit but its a terrible idea to use large JS on Forms. you may rather create a html5 /JS extension.

    dynamicday.wordpress.com/.../jquery-and-sdk-rest

    large Jquery or massive JS are not recommended by Microsoft on the CRM forms

  • Suggested answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hi Burno,

    Thanks for your reply. I'm not using Jquery. My code contains only Java Script

  • Verified answer
    Bruno Lucas Profile Picture
    5,421 on at

    you can write very long JavaScript, the guideline is here and doesn't mention maximum amount of lines:

    msdn.microsoft.com/.../hh771584.aspx

    but the idea is that longer JS takes longer to load and slow down the form.

    if you have hundreds of lines on a onload function, it may not slow down. it depends of what it does and how long it takes to run.

    when you have a ribbon button calling a long JS function, the button will display a blue (pressed) color and stay like that for a long time. I've seen people put such slow JS on the ribbon that the button freeze an throw a time out error.

    so, pretty much is more on how fast it run, and depending of the infrastructure, hoe long the client takes to load  a larger JS.

    if may run this to check the performance of your JS:

    blogs.msdn.com/.../using-the-crm-diagnostics-page-to-capture-network-performance.aspx

  • Verified answer
    Hosk Profile Picture
    on at

    I would split the javascript code into seperate scripts.  I don't think there is al limitation but it's harder to work with massive javascript files because you can spend ages scrolling around trying to find certain functions.

    It would be a good idea to split the code into common functions then you can use them in different entities.

    It will also mean it is easier to maintain if you group your javascript functions into logical groups, not only for this project but also other projects.

  • Suggested answer
    Jitendra Sahu Profile Picture
    2 on at

    HI VE,

    I have also written JS code with more than 1500 lines.

    I will suggest you to break your code in functions and multiple script blocks which you can refer in one go.

    For best practice you can refer below Ben's article

    community.dynamics.com/.../crm-2011-2013-javascript-programming-best-practices.aspx

  • Verified answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Thank you Guys.

  • Community Member Profile Picture
    on at

    Thanks for the insight. Good for newbies  like me.

    Harihar

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans