dcsimg
Results 1 to 7 of 7

Thread: How to compress JS code to the minimum size with VB6?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,744

    How to compress JS code to the minimum size with VB6?

    My web pages need to call some JavaScript code, which has 10-20 thousand lines. In order to increase the speed of loading web pages, I want to compress these JavaScript code to the minimum size with VB6. I'd like to know if there is any good way to achieve this? Thanks!

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,779

    Re: How to compress JS code to the minimum size with VB6?

    Isn't the first cut to gzip the file?

    Beyond that you probably need a parser/analyzer that can build a symbol table, then rewrite the script using short variable names and squeezing out white space including comments.

    There might be more tricks, but I'm not sure why you'd come to a VB forum to ask any of this. Sounds more like a question for the JS forum here. The challenges should be the same no matter what you program in.

    Python forums are big on code handouts and all of the cool kids are there. You might try some of those, they seem to be a dime a dozen.

  3. #3
    Addicted Member
    Join Date
    Mar 2017
    Posts
    192

    Re: How to compress JS code to the minimum size with VB6?

    Would keeping the java script on the server work

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,638

    Re: How to compress JS code to the minimum size with VB6?

    Quote Originally Posted by dreammanor View Post
    My web pages need to call some JavaScript code, which has 10-20 thousand lines. In order to increase the speed of loading web pages, I want to compress these JavaScript code to the minimum size with VB6. I'd like to know if there is any good way to achieve this? Thanks!
    I wouldn't recommend building something with VB6 (or any VB) to do this ... Look at minify and jscompress.... if you google "javascrip minify" they should be the first couple of results. They're existing tools that do exactly what you're looking for. I've used miniify before - not directly, but as part of a built process, and it does a pretty good job of shrinking things down.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,744

    Re: How to compress JS code to the minimum size with VB6?

    Quote Originally Posted by dilettante View Post
    Isn't the first cut to gzip the file?

    Beyond that you probably need a parser/analyzer that can build a symbol table, then rewrite the script using short variable names and squeezing out white space including comments.

    There might be more tricks, but I'm not sure why you'd come to a VB forum to ask any of this. Sounds more like a question for the JS forum here. The challenges should be the same no matter what you program in.

    Python forums are big on code handouts and all of the cool kids are there. You might try some of those, they seem to be a dime a dozen.
    Hi dilettante, thank you for your reply.

    I know that writing a JS parser/analyzer can solve the problem completely, and I've always wanted to do this (write a JS parser/analyzer with pure VB), but I hope to find some clever solutions. Writing the parser/analyzer in the traditional way is not only a lot of work, but also has little practical value.

    I hope that all processing of JS can be done with VB6, so I put the question in the VB6 forum.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,744

    Re: How to compress JS code to the minimum size with VB6?

    Quote Originally Posted by Ordinary Guy View Post
    Would keeping the java script on the server work
    Hi Ordinary Guy, thank you for your reply. My JS code is used to process the client's web pages. As for the server-side work, I still want to use VB6 and RC5 to handle it.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,744

    Re: How to compress JS code to the minimum size with VB6?

    Quote Originally Posted by techgnome View Post
    I wouldn't recommend building something with VB6 (or any VB) to do this ... Look at minify and jscompress.... if you google "javascrip minify" they should be the first couple of results. They're existing tools that do exactly what you're looking for. I've used miniify before - not directly, but as part of a built process, and it does a pretty good job of shrinking things down.

    -tg
    Hi techgnome, the tool you recommend is great. But my web pages are dynamically generated by my web tools, and JS code needs to change dynamically, so I need to use VB6 to write a JS minifier for my web tools. Thank you, techgnome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width