Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4124716
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:46:33+00:00 2026-05-20T23:46:33+00:00

We are creating a javascript library from scratch and we need some utilities functions,

  • 0

We are creating a javascript library from scratch and we need some utilities functions, just like what dojo provides, e.g. xhr wrapper, simple inheritances and array manipulation, etc. We don’t want to write these functions ourselves from scratch, but we also don’t want to just copy and paste code from dojo.

Dojo provides the custom build mechanism, but it works on the module level. For example, in the custom build, you can specify to only add the lang module in the dojo base. But we may only need the dojo.hitch function in the lang module, but not the dojo.clone function that also included in the lang module. We have a tight constraint on the size of the library file, so we need to remove any unused code.

What we are seeking is a way to extract certain functions from a module and build these functions into a single javascript file. For example, say we need dojo.mixin, dojo.declare and dojo.hitch functions, then these functions’ declaration and their dependent inner functions should be built into a single file.

Any suggestions?

Update from my test result

Thanks Stephen Chung for your great suggestion on how to solve this problem.

So basically I created a custom dojo build with four modules : dojo._base.xhr, dojo._base.json, dojo._base.declare and dojo._base.lang. The built dojo.js file is 149kb, after using Google Closure compiler with advanced mode, the size has reduced to 24kb and the unused functions have been removed. If we want to keep some functions, just add another javascript file like below:

window['dojo'] = dojo;
window['dojo']['requireLocalization'] = dojo.requireLocalization;
window['dojo']['moduleUrl'] = dojo.moduleUrl;

and compile it with dojo.js.

Unfortunately the size is still a little bigger. We have a size limit of 40k in total. But this is still a very good solution for other cases.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:46:33+00:00Added an answer on May 20, 2026 at 11:46 pm

    Dojo Core is written in a very compact manner, with a lot of cross callings (i.e. one function calling other functions) in order to save download bytes and reduce code size.

    Therefore, you need a minimal set of Dojo Core functions, together with the functions that it calls.

    In other words, what you need is a build that includes Dojo Core, but then removes any dead-code that is never called.

    I’d suggest that you don’t go about creating a minimal-footprint library by writing it from scratch yourself. What you need is to use the Closure Compiler’s Advanced Mode to process your Dojo application. It removes dead code, optimizes the entire app, and fully obfuscates it.

    And yes, it is possible to use the Closure Compiler with Dojo in Advanced Mode — Dojo is probably the only popular library that can do it. Read it here.

    Some statistics: A Closure-compiled Dojo app is typically around 25-30% smaller than the equivalent Dojo app in a Shrinksafe build. It depends on how many Dojo Core features you use — typically you may reduce Dojo Core up to 40% of the original size (i.e. reduce code size by up to 60%) from dead code removal alone. Further reductions are more difficult, as you may have to start removing features like the Dojo loader etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a GWT wrapper round a JavaScript library. One of the JavaScript functions
Is there any JavaScript/jQuery library for creating step-by-step forms? It's better if it has
I'm having some difficulties creating a javascript appointment style calendar. While it does render,
I'm testing some cookies that I'm creating via JavaScript. Is there a way to
I'm creating an SVG rectangle using the Raphael JavaScript library, and assigning it a
I am creating a webpage which needs to pull in a Javascript library which
I'm creating a new slider that will integrate with my self written Javascript library.
I'm creating a sophisticated JavaScript library for working with my company's server side framework.
I'm creating a game engine, or more like a large library of useful classes
I'm working on creating a Javascript Tab library. Actually, it's already been developed and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.