r/GoogleAppsScript • • Jun 07 '19

Just how large a script can a write while maintaining reliability?

This is my first script and i've only been coding for a month. At this point i'm at 600 lines of code and 4 HTML sidebars attached to a google sheet. It is fully functional and reliable. I'm somewhat obsessive and have really dived head first into coding.

  1. Does the size of the code and html files increase the amount of time it takes your menus to populate and become usable?

  2. I'm at 600 lines of code now. How much can I write before stability becomes a factor. I have big plans and much more to write.

I'm loving coding. I haven't played computer games since I started. This is incredible. I wish I had tried this sooner.

7 Upvotes

10 comments sorted by

2

u/AndroidMasterZ Jun 07 '19 edited Jun 08 '19

I'm not sure about the line limit(heard it's 10mb/file (or 50mb), I'm not certain It's 10 mb/project[Around 700k lines]). You can split up the code into individual js files. Size of code is probably inversely proportional to speed, but the effect should be negligible, provided the code is well compartmentalized and follows best practices.

1

u/c_for Jun 08 '19

Thank you. How do you check the current file size? I've search the menus in script editor but haven't been able to find them.

3

u/AndroidMasterZ Jun 08 '19

Found the source: Click here

1

u/c_for Jun 08 '19

Wow! Those are some big projects. I think it will work fine for anything I will ever create.

1

u/AndroidMasterZ Jun 08 '19

If your code ever gets that long, there are minifiers out there, which will minify your code(as well as make it unreadable by a human). Most frameworks/libraries provide a minified as well as a main/debug version(like jquery min and jquery).

1

u/ppc-hero Jun 08 '19

If your code ever gets that long, there are minifiers out there, which will minify your code(as well as make it unreadable by a human). Most frameworks/libraries provide a minified as well as a main/debug version(like jquery min and jquery).

Minifying is for front end, and has no place in the back end (like google ads scripts). *Do not minify your ads scripts.

1

u/AndroidMasterZ Jun 08 '19

Why so? Agree that server runs stuff faster than the browser engine. Still, minifying does reduce variables memory imprint. Even if not, if he reaches 10mb/project, he can reduce the size of code. Agree that the profit is negligible in most cases.

Regardless, in context, OP has significant front end code:

and 4 HTML sidebars

Does the size of the code "and html files"

1

u/AndroidMasterZ Jun 08 '19

You can't. Each ascii character=1byte. You can copy/paste the code file in another editor to find the size. If you haven't already, use `clasp`

2

u/ppc-hero Jun 08 '19 edited Jun 08 '19

Ive written ads scripts over 20k lines, some of them run every hour on $100k/month accounts.

The amount or length of code has nothing to do with speed or stability. The content of the code does.

The same goes for the editor interface. Length of the code has no detectable effect on the rendering, or the stability of the editor.

For readability, you can split your code into several files (left hand side of the editor shows you the files). Make sure to comment and structure responsibly.

1

u/c_for Jun 08 '19

For readability, you can split your code into several files

Oh!!!!! That is great. I'll look into that. Once I got to about 300 lines I became more careful about using the code more efficiently. The 'programming like a grown up' video from the 'Learn Google Spreadsheets' youtube channel really helped. But at this point it is becoming more of a task to scroll around the page. That should help a lot.