effects of using underscorejs templates on SEO - templates

I have a website where I am using underscorejs.
I have many templates(underscorejs) included in the HTML.
there are cases where unnecessary templates are being read on the pages.
Does this effect the SEO rating of my site.
I have heard that Google Search engine reduces the ranking of your site if it finds no Javascript code within <script> tags.
and while specifying underscorejs templates we specify it
<script type="text/template" id="XXX"></script>
PS: I understand that readig unnecessary templates is not good , but this is done from a long time in the site and I dont intend to edit it anytime soon.

The problem I see here is that, since you are using templates that are loaded via Javascript (e.g. Underscore or Handlebars), some search engines will have problems to index your website (although there are techniques to improve indexation).
I imagine that you are building a single-page web application which is rendered in the client side via Javascript using Underscore templates; and I guess you are making AJAX calls to the server to do CRUD operations if needed.
The problem with the SEO in single-page applications is well known. Here is an interesting article (specially interesting if you are using BackboneJs).
Also here is a thread in Stackoverflow dealing with Single-page web applications and SEO.
One more resource: "Making AJAX applications crawlable" from Google.
I hope this helps.

Related

When to use Angular with Django?

I have a pretty basic question.
Consider a CRUD web application built on Django. You have templates that render data. Those templates might have forms where you submit data to the backend, and that might reload the page to display changes. Sometime, you can make those requests over AJAX, for example when you need to update data on the UI. You can also submit forms with AJAX and update the HTML with it.
On the other hand you have single page applications. You serve a static file, and there is no reload of pages. You have data that comes from an API and populates some front-end template.
What are some guidelines for when to use what? Not in a mutually exclusive way, but within one Django project, what are some reasons/considerations to use a Django template/forms/AJAX approach and when to use Angular?
Thank you.
Something to consider is how "interactive" you want the client-side to be.
I am in the process of converting an existing Django app to use Angular (and django-rest-framework). The app was highly interactive and relied on a lot of custom JQuery to get various widgets working just right. JQuery's constant looping through the DOM made it pretty slow. I am finding that using Angular instead of JQuery is much faster.
So if you have a lot of complexity in the front-end, I would recommend Angular.

preventing XSS/JS attacks on hosted CMS

I am working on a hosted CMS, and am thinking about allow site editors to add custom javascript and html (a much requested feature).
I am concerned that this will open up an attack vector - nasty js could make calls to the functions that our hosted CMS exposes (see the Samy worm for an example of what user scripts did to myspace), but I really want to give users control over their site (what's the point of a CMS you can't add your own clever stuff to?)
What is a good approach to fixing this issue? I can think of several which I would like commentary on, but am not going to list them for fear of the 'no list questions mods'!
I suspect that Caja is on your list, so I'll mention that this is squarely in Caja's use cases; for example, Google Sites is very like a CMS and uses Caja to embed arbitrary JS and HTML.
Caja host pages can provide arbitrary additional interfaces for use by the sandboxed content, which can include, for example, embedding widgets provided by your CMS inside the user-supplied HTML while maintaining encapsulation.
(Disclosure: I work for Google on the Caja team.)

Server Side Includes as a Site Template

I am an ASP.NET MVC / WebForms developer by trade, so all of the websites/apps I have created in the past allowed me to use Master/Layout pages for the look/feel of all my site, while allowing me to change just the parts specific to that page.
Now, I am doing some freebie web work for a friend and I want to write it in HTML, CSS, and JavaScript using Aptana 3 so that it can be hosted wherever. Master pages are not an option for me since I am no longer in the ASP.NET/Visual Studio world, so I am looking at Server Side Includes to accomplish this. My question:
Is this a good use of SSI? I am seeing conflicting forum posts, where some say that they should be used for small pieces of the page (like a specific piece of text, time, etc). I want it to generate a large portion of my page, things like the footer, footer links, menus, banner image, etc. Basically, I want to use SSI for most of the page, and then just plug in the pieces specific to the page. Have others done this in the past with success?
If the purpose behind you choice is so that it can be hosted anywhere, then even using SSI may be restrictive since it relies on that functionality being enabled on a server.
Having said that, it is a valid option, but personally I would familiarise yourself with both the options in PHP and .NET so that you are comfortable in adapting your code to both. You are rarely going to be asked to move a site hosted on one framework to another, and if you are then you can factor changing the code into your costs.

Emulating a web browser to wrap the functionality of several similar web sites

I'm interested in emulating the functionality of a web browser in C++ so that I can create a wrapper for several web sites. Right now, the biggest issues with these sites are that they make heavy use of JavaScript that interacts with the HTML DOM. Thus, the simple solution of using curl to download the page, and something like RapidXML to parse its contents is out.
Next, I considered using something like v8 with curl, and that solves the issue of interpreting the JavaScript on the page nicely. However, it doesn't solve the issue of connecting the HTML DOM methods with the JavaScript; in other words, document.getElementById() would fail in v8.
Next, I considered WebKit, which seems like it's perfectly suited to emulate a web browser--after all, Chromium and Safari both utilize it in their web browsers. However, it's a little too complete. I don't need all of the rendering aspects it includes.
So, I'd be looking for some way to:
Make an SSL connection to a web site
Interpret the JavaScript on that web site in connection with the HTML DOM
Set the value of the username/passwords <input> fields with my username and password
Simulate clicking the "Submit" button by calling the formSubmit() function, from <input type="button" onClick="formSubmit()">
Handle the HTTP POST form action and the subsequent HTTP 301 and JavaScript redirects (accomplished using window.location)
Repeat 2-5 as needed
Besides what I've already considered, what other options do I have? Ideally, I'd want this to be extremely lightweight, without requiring linking to many libraries.
I'm primarily concerned with developing for Windows 7 64-bit.
Well, this sounds all too much like a brute-force program. Disregarding that, and since you don't seem to need to render any website, I think you should just fetch the file through cURL or something, then parse it, check for the form through using a regex, retrieve the form action, then make a request using the method taken from the <form> tag and whichever input you want.
Problem is, there would be no proper way to know when is it that you've logged in properly, unless you made some kind of per-site checking. This comes mainly from the fact that many sites use sessions rather than direct cookies or HTTP auth, and since you can't read from sessions directly, it is impossible for you to guess when the session has changed.
That's the most lightweight solution I can come up with right now.

Pass array from HTML to Django application

I developed an application in JSPs and Servlets involving drop down menus that kept growing with how many authors per publication their were.
This was done in JavaScript and then in my application iterated through them using a loop. Is this possible using Django? This would be useful in my application.
This link might help you out if you don't want to dive into javascript (too much)
http://www.dajaxproject.com/
Or have a look at this stackoverflow question/awnser:
What is the best AJAX library for Django?
In any case, you need to serialize your array to a JSON string.
Then pass the JSON with an XMLHTTPRequest (ajax) to the server.
Add the javascript tag to your question if you don't mind more JS solutions.
Otherwise look for a Django Ajax framework to do the heavy lifting for you.