1

all

I have a several js files. It's splitted js library. I need to combine it into single file. The difficulty is the resolving ordering of combining files. Because in Js it's important the order of combining.

Do you know any tool or maybe advice my approach to this.

Thanks.

1
  • Are you looking at a pure JS based solution or are you some kind of server side solution? Based on your server side implementation, the approach and tools will vary. What are you using: asp.net? php? something else? Commented Jun 24, 2011 at 15:00

2 Answers 2

1

Pyramid js is a library that handles this situation. It does some important things other javascript dependency managers don't do, mainly

  1. Handles other files (including inserting html for views...yes, you can separate your views during development)
  2. Combines the files for you in javascript when you are ready for release (no need to install external tools)
  3. Has a generic include for all html pages. You only have to update one file when a dependency gets added, removed, renamed, etc

Some sample code to show how it works during development.

File: dependencyLoader.js

//Set up file dependencies
Pyramid.newDependency({
    name: 'standard',
    files: [
    'standardResources/jquery.1.6.1.min.js'
    ]
});

Pyramid.newDependency({
name:'lookAndFeel',
files: [
    'styles.css',
    'customStyles.css'
    ]
});

Pyramid.newDependency({
name:'main',
files: [
    'createNamespace.js',
    'views/buttonView.view', //contains just html code for a jquery.tmpl template
    'models/person.js',
    'init.js'
    ],
    dependencies: ['standard','lookAndFeel']
});

Html Files

<head>
    <script src="standardResources/pyramid-1.0.1.js"></script>
    <script src="dependencyLoader.js"></script>
    <script type="text/javascript">
        Pyramid.load('main');
    </script>
</head>

Note: I'm biased as I just released this tool.

Sign up to request clarification or add additional context in comments.

Comments

0

In what order are you currently including the various scripts on your pages? That is the order with which you should start.

If you run into dependency errors after that, you can then work through each specific problem. As you work through those problems, you can ask more specific questions here on SO and provide code samples.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.