I'm developing a simple node-webkit app which is similar to a product catalog. So I have lots of images, around 1500!!
Currently, I'm done with implementing and using Grunt(grunt-node-webkit-builder) for building .exe. After creating an exe file, I use IExpress to make nw.exe and helper DLLs all-in one place. Because some of users doesn't like when setup looks messy. So I have two steps:
Make a build with Grunt
After the Grunt build, use IExpress to make it one .exe
In both cases, all the images are located in the application(around ~250MB).
My problem starts when the users clicks on the application. The time of opening application is around 30-40 seconds! I need to figure out how to decrease time!(btw, in development, it is super fast)
I thought that may be if I get images from external path and caching them make the performance better. But I don't know or I have no idea how to get images from external path after using IExpress!! Maybe there are better solutions or workaround even images are located at internal path. Could you suggest me how to solve this problem? Thanks in advance.
I had the same issue as you and i don't know if you're stuck on this or you found a solution, but searching through the NWJS google group i found this:
var path = require("path");
pathstr = path.dirname(process.execPath);
This returns the path where the NW bin is running. Just treat the string to fit your case and access the external files
Related
I'm new to web development (more of a data science background with R), but I feel like this has to be possible and pretty simple, but I'm stumped. On my main index page, I want to include a list of all files included in my pages directory as links. I want this so I don't have to set up the links manually every time -- instead, links will be created for a page when it is saved in the pages directory.
My first thought was that there had to be a way to read the files in the directory, and from there I could build my list of links. It seems that JS can't access the server side to read the directory, though (if I'm understanding this correctly).
On this answer they suggest using Node.js with the following code:
var fs = require('fs');
var files = fs.readdirSync('/pages/');
I tried dropping that in my index page as I would javascript code, but that didn't work. If this is the solution I should pursue, where do I put the node.js code in my website directory? If it matters, I have the site hosted on GitHub.
I'd appreciate any guidance on this -- and I fully accept that I might be going about this in completely the wrong manner.
I develop an angular-php web application which I have it running online, for different users, on 5 different subdomains, such us:
sub1.mydomain.com
sub2.mydomain.com
sub3.mydomain.com
sub4.mydomain.com
sub5.mydomain.com
Problem:
My problem is that I still develop the web-app local and whenever I change files(php, js,tpl.html,css or when add new ones) I have to upload them on each subdomain.
Question:
Is there a way/library/API whatever that I can use to make something like package (with the updated or new files) and just call it from each subdomain url , and make the appropriate updates?
Or should I just copy them to each subdomain?
Do I make myself clear, in other words just like on cms systems that we press the update button and we update a component/module.
If anyone knows a way of doing that please enlight me. Thanks.
I tried to depict what i mean.
What you are describing is called deployment.
There are a lot of ways to create a deployment mechanism so there is not a single answer to your question. Depends of the tools that you are using, the servers where your app is hosted, etc.
If not, I advise you to use Git to make versions of your app (with Github or Gitlab) and automate the deployment process when you push a new piece of code.
You can make your own scripts to deploy or use online services (surely what you need because of "systems that we press the update button").
I can't advice you one particular service but you would find what you need in Googling "deployment automation github".
I would do it with config files. Considering the code for all my substations is the same. I would have config for each sub-domain and fetch the core files from the same location but serving different data If your structure allows it.
Thought I would open this question to the javascript community. Does anyone know if its possible to combine CKEditor into 1 file? I want to try and integrate it in one of my desktop applications which uses a web viewer - I can execute one flat file in my web viewer internally in my application otherwise I'll have to reference to the CDN which I'm hoping to avoid. I want to develop an app that does not require external web service.
Performance should not be an issue as the file would be in my application running locally - I would include all the licenses/readme etc etc.
Is there a tool out there that can help me to achieve this, and has anyone done it or is not possible due to the architecture - the way CKEditor has been written?
Thanks
CKEditor loads some JS files on demand (i.e. dialog definitions). There are also several skin CSS files, sprites with icons and separate langfiles. I hardly think there's any reasonable way to combine all these resources into a working JS bundle without architectural changes.
I'm very keen to make use of some build techniques in my Javascript/Web App development such as
Concatentation
Minification
Image replacement with data:uri's
Build vs Source *
App Cache Manifest generation *
It's those last two that I haven't found an answer for yet.
Build vs Source
By this I mean having a "source" version of my HTML and Javascript that is untouched so that I do not have to build each time to preview a change. All of my JS files are separate <script> tags as usual with the build vs updating these script sections with the final concatenated versions. To be honest I feel like I'm missing something here with all of these new Javascript build systems as this seems like an obvious need but I can't find anyone else talking about it. How is everyone else dealing with this?.. Build on each change during development?? surely not.
App Cache Manifest generation
This explains itself - walk through my source tree and build up a manifest and insert it into my <html> tag.
I've searched for these two with no luck - any pointers?
I'd be on the road with a killer build system if it wasn't for those two.
Thanks!!!
Re: Build vs Source
It sounds like you're already familiar with grunt. You may want to consider looking into the grunt node-build-script plugin.
It adds a number of new tasks, notably grunt mkdirs and grunt copy which duplicates your project directory into a separate staging folder and then copies your optimised project into a publish folder. If I'm not mistaken, this is what you mean by keeping an 'untouched' version of your source files?
Running grunt server will then serve up the contents of your publish files on localhost. You could always point your web server to your initial project directory if you want to examine your application in its unoptimised state.
node-build-script adds a bunch of other super convenient tasks, such as image optimisation, automatic file revving and substitution. It's incredibly easy to use and super customisable.
I have a basic single page template which uses node-build-script which also may be of interest.
Re: App Cache Manifest generation
I believe this used to be part of node-build-script but was since removed, see 1, 2
There would be nothing stopping you from creating a custom grunt task that utilised something like confess.js however.
Finally, it looks like Google's upcoming Yeoman might be worth keeping an eye on if you're not already!
First, my html locates things relatively on the server. Do I need to change these to the full urls so it knows I don't mean localhost?
Where is the line between what you package in the app and what you grab from the server? Do you package all of your JS and CSS. Do you also grab scripts from the server sometimes? Do you package images and also grab some images dynamically?
Any other things to keep in mind when starting out a port of a web app to phone gap? Just having a hard time figuring out exactly where the lines are usually drawn as far as assets.
Thanks very much.
Do you care what happens when your user loses his connection to the internet from his phone? If not, then you can reference CSS and images from the server. However, if you use the min version of jquery, you can just embed it all in your application and then you won't have to worry as much about lack of connectivity.