Tinymce compress other than tinyMCE_GZ.init - javascript

In continuation with the below post is there any way to take ahead the build.xml and add all the plugins such as table, save etc and compress it with the same build.xml file. Reason is to have one ant script file to compress all the files into one, not only the tinymce js files but also other project related files.
tinymce build script to compress all js files
I know the compressio is possible by declaring additional tinyMCE_GZ.init but why use two methods of the compression in same project. It would nice to have as described in above post using build.xml.
How does the plugin structure works it is possible to take everything in one file & still intantiate plugin, right now when I take out all the script tag from table plugin (i.e from table.htm) file I get javascript error even though the script tag is available into the parent html file from which table plugin is invoked..

I tried that, but i failed. I won't say it is impossible, but it will be pretty difficult to achieve. What i ended up doing is to use two compessing methods.

Related

Meteor css and javascript files loading best practice

TL,DR: How to load css and javascript files independent of Meteor assumptions about alphabetical order (which is far from how it works in practice.)
Stackoverflow tells me this question might be subjective but I hope not.
Meteor loads files based on alphabetical order (and other rules.)
So to force it to load the CSS and JS files in the order I wanted, I had to start the fiels with numbers that indicate the load order. If I have jquery.js and bootstrap.js, Meteor will load bootstrap.js before jquery.js. But bootstrap depends on jquery so jquery must be loaded first.
In order to solve this, the options are:
1. Put the files in the public directory and manually load them. But this didn't work as Meteor appears to be sending the files with text/html MIME type.
2. Create a Meteor package and specify the load order from there. I find this like hitting a fly with a hammer just for loading CSS and Javascript.
3. Put a number before every file. In the previous example, to load jquery before bootstrap, rename the fiels to 1.jquery.js and 2.bootstrap.js This works and is tedious but at least I get to load the files the way I want them to.
I am new to Meteor so I am wondering if there are recommended best practices concerning this. I was thinking of using AMD for javascript but that's limited to javascript.
Its an interesting question and this is probably one of the pitfalls of making a Meteor app.
You've mentioned all of the usable solutions such as creating an explicit package or renaming the files.
The best way I would think is to use the atmosphere packages. For example if you add bootstrap, jquery is a dependency of it so it will always load first. Most js libraries that involve load order are typically on atmosphere.
The other best way if there's no atmosphere package, though i'm not sure I would say is tedious is to put a number in front of the js file to indicate load order.
One thing is when you use the /public folder the files map to /, so you can load the js file yourself manually in the order you would want (in the root html file using /public. Meteor returns the text/html MIME type as its version of a 404 file not found error. This method is a bit troublesome though because the files are seperated in production and can cause trouble if one or the other dont load.

Include js into pure js file (not into html file including js)

This is driving me slightly bonkers, since it must surely be an easy thing to achieve. I've spent hours searching for the solution, but can only find a solution in the context of html (with embedded JS code).
I have a native javascript file (.js not .html), and all I want to do is to include/embed/load the code in from another javascript (library) file into that file. This is NOT html I'm talking about, it's pure unadulterated javascript. The solutions I've seen are all along the lines of http://ntt.cc/2008/02/10/4-ways-to-dynamically-load-external-javascriptwith-source.html.
All I want to be able to do is:
include('./lib/cooljslibfile.js');
// ... now use functions etc defined in the above library file
Surely, to write re-usable code that can be deployed in multiple scripts, there must be a way other than just copying and pasting the contents of cooljslibfile.js into my javascript file?

html Multiple file select and queue (add/delete)

What i want to do is to be able to select multiple files using the multiple attribute on tag but when starting to upload ( POST) each files will be uploaded individually + having the possibility to remove a file from the queue(this is what makes things even much harder, because adding files is not a problem since i can easily create another element but removing is impossible).
Now for security reasons its impossible to alter a file tag in html! so far what i have done is having a single file input and when selecting a file, a new element is created in its place so i am giving the illusion of a queue and then using jquery i upload each file individually! ( cant select multiple files at once but everything works)
I have found some flash plugins but i don't want to depend on more libraries, if it was a simple flash file no problem but most of those plugins need additional js files etc...
I would be happy to see a cross-browser solution. Again i know there are some flash plugins that can do this, but i am after a cleaner and simpler way maybe a single swf file or something ....
Thanks
Im pretty sure uploadify does all of this, and in a single simple small swf.

How do I compress tinymce and all plugins into a static file?

The documentation for tinymce notes that one can compress all the javascript and components (which I assume includes plugins) into a single file. They do note reasons why one might not want to that as well.
Compressing into a static file
It's also possible to simply concatenate the necessary components and some boilerplate code into a single .js file. However you will always have to recreate this file if you want to use other TinyMCE plugins, or you upgrade TinyMCE. You will also probably want to configure your webserver to compress javascript files.
But assuming one actually did want to do it, how does one actually go about it? Build.xml does does not provide an appropriate task it seems. At least when I tried it the plugins did not seem to be included when I loaded tiny_mce.js.
There are some really excellent command line tools for this, but you can also do this easily with just a text editor. The simplest way is to just open each file, copy the contents, and paste the contents into a single JS file ("everything-all-together.js", say). You'll need to make sure you paste the files into the single file in the same order you would've put the script tags into the HTML doc. Once you have all the files all together, you can use tools like JSXMin, YUI Compressor, or Google Closure. There are also some tools online that do this, like http://www.minifyjavascript.com/. You can paste in the uncompressed JS and copy back out the compressed JS. This makes the build process really cumbersome, but if you just need to do this once, that will get you there.
The best way to do this is to do it as a build step for the site. That means when you make changes to the JS files, you rebuild the compressed JS file to include the changes as well. This can be a cumbersome step if you're iterating quickly and changing files over and over again. You don't want to have to rebuild the compressed file with each save. You can solve this by setting up development and production modes of the site. When being loaded in development mode, the JS files aren't grouped together. When all the necessary changes are made, you'd rerun the build step to generate the single compressed JS file. To do the minification from the command line, you'd probably want to use Google Closure: https://developers.google.com/closure/compiler/. If you download the compiler app, you can do the following:
java -jar compiler.jar some-file.js some-other-file.js > compiled.js
That will generate a file called compiled.js that includes the contents of some-file.js and some-other-file.js in a minified format. You can specify as many files to compile as you need to. Actually, I'm selling Closure a bit short to say it's just minified. It's also extremely optimized code. Pretty much every site should be doing this to all of there JS all the time unless they're already doing something better.
I hope I'm getting you (and the tinymce docs) right, but this sounds a lot like combining JavaScript files on the server side. This means taking the contents of all of your JS files, putting them into one file and returning that one to the client.
Why would you do that? Well, this should be obvious, but.. you reduce the number of HTTP requests to your server, which is always a good thing.
How do you do that? There are many solutions out there for all server-side languages and frameworks, I suggest doing a Google search for "[your language] javascript minifier" or something similar.
Hope this helps.

Uploading html file generated from R-animation package to wordpress

I created a HTML file using the animation package in R. Now I'm trying to upload the resulting HTML file to a wordpress blog but don't really know how to make it work. It seems like I might need to upload some js or css files too but am not sure. Also, it seems like I might need to upload the original data files as the HTML file is 2.5kb and the original CSV file is 2500kb. Any suggestions would be appreciated.
I think I have addressed this issue in ?saveHTML if you are using the latest version of the animation package (the second paragraph in the Note section). Perhaps it is still not clear (I'll improve it in the next version), so let me explain it here:
What you need to upload are: the HTML file, the image folder, js and css. The CSV data is not required, since the animation is independent with the data now.

Categories