Do jade extends/include system means no whole page reload ? - node.js

is there is any other way than AJAX/WebSockets to implement partial-page reloads, in node.js applications ?
I was told that template engines with a block/includes functionnality like Jade's do that, but when I open up Chrome DevTools on simple apps built with it, it seems it's still a whole page reload.
Thanks

Jade engine compile template file to minified HTML but included blocks still result to a full HTML page, no partial loading. If you want something more dynamic I guess ajax/ws is best way.

Related

Can I use browser's website code to recreate a website by my own way(change design, etc)?

For example, we have a cool styled website, can we use developer options(f12) from browser to snatch this?
Ignoring any legal / copyright implications, you can grab the client-side code this way, yes. All HTML, CSS, JavaScript and imagery can be seen through the F12 Developer Tools.
However, there is no way to know what server-side code a website is using (outside of the server owner themselves configuring something incorrectly and thereby exposing that information).
The answer from Obsidian Age is a good one. I'm going to add some more information that may be useful to you.
I've used this technique myself of getting source code via the developer window. Usually I want to find out how they did some neat CSS or JS trick so that I can try it in my own apps.
The files that make up a website such as HTML, JavaScript, and CSS you can find in the Network tab and can easily copy these.
However you should know the JS, CSS, and even (sometimes to a degree) the HTML files have been minimized and are typically missing any comments from the original developers. Chrome has a nice feature that will un-compress JS files and you can even set break points and step through the JS code.

crawling url \ how to get dynamic links in node.js

I'm using js-crawler to crawl websites, and encountered now with CNN, that part of its landing page links are inside (urls that are generated dynamically, for some reason).
Thing is crawler don't really touch scripts - how should I address it? should I write my own code in addition to my node.js crawler? is there advanced crawler that knows how to handle this dynamic behavior?
Making my comment into an answer:
Crawling content that is generated by client-side Javascript is a complicated problem that not even Google has fully solved.
The only way to truly do it is to use some sort of head-less browser that is safely sandboxed on your server where the page is loaded into a browser-like environment where it can run its own scripts and generate its own content and then you can examine the resulting DOM.
Even then, it won't necessarily generate content that requires user interaction (like clicking on a tab to show some content).

Is it possible to save an html page that still uses jQuery and JavaScript?

Is there a way to save an html file that still contains the user interactions of jQuery and JavaScript?
Because JavaScript and CSS are client-side (meaning they run in the browser), yes, you can save the page and use it off-line.
If the JavaScript and CSS are embedded within the HTML then you can have it work as an all-in-one page.
If you right-click on a page and "view source" you can easily download the code.
Note that any server-side interaction (such as PHP, Java, etc) will not work this way.

Controling Jetbrains built-in server programmatically

I use WebStorm and it comes with awesome LiveEdit function, and it's totally much better than LiveReload, however it doesn't automatically register changes in all different types of files I'm using. It ignores changes in Stylus and Jade and I need to manually trigger reloading the page anyway.
I guess because LiveEdit doesn't reload entire page, but only relevant parts, and Webstorm of course can't possibly know what needs to be redrawn on the page, when dealing with Jade or Ejs templates
For that matter LiveReload feels to be a better solution.
But I was wondering if it's possible to trigger reloading the page by sending signals to "JetBrains IDE support extension" somehow?
So ideally grunt-task, or gulp-task (I'm using gulp) would watch files for changes and send signals (maybe to WebStorms built-in server) and extension would reload the page. Is that possible?
Can you control Jetbrains built-in server with node?
No. The extension doesn't have the API
However, LiveEdit does normally work for Jade (no hotswap, of course - just page reloading). When Jade is compiled using a file watcher, live reload is correctly triggered. It also works when Jade is compiled with Express. What does your workflow look like? How do you compile Jade, Stylus and other files that aren't natively executed by the browser?

How should I go about rendering a webpage without using a browser?

Basically I am currently doing some research, and I am interested to find out how I could render web pages without a browser: I have some algorithms that I would like to run to calculate the visual aspect of each blocks of DOM node(s) for each page.
What you're asking for basically, is a browser rendering engine, otherwise known as a layout engine... For example, Firefox uses the Gecko layout engine to render the pages. Theoretically, you could adopt this engine for whatever project you're working on, saving you a lot of time.
The Gecko engine is used in more projects than just Firefox, and since it's open source, you could easily get the source code and try to throw it in an application.
Wikipedia has a nice list of layout engines, so there are other alternatives to Gecko, like GtkHTML.
Basically, you want to create the data structures a browser internally creates so that it knows how to render the page.
Check out the Firefox source.
I suspect it's rather complex.

Resources